import ResetStyle from '@/pages/OrderModule/common/components/ResetStyle';
import React, { useMemo } from 'react';

/**
 * @desc: 筛选框：筛选Item
 */
export const FilterItem = (params) => {
  const { Component, props: _props, id, forwardedRef, ...args } = params;
  const props = useMemo(() => {
    if (typeof _props === 'function') {
      const formApi = Form.useFormInstance();
      return _props(formApi);
    }
    // if(id == 'orderState'){
    //   console.log(params, args)
    // }
    return _props;
  }, [_props]);

  const enhancedProps = {
    ...props,
    id,
  };

  return (
    <div className="filter-item" id={id} ref={forwardedRef}>
      {React.createElement(Component, {
        ...enhancedProps,
        ...args,
      })}
    </div>
  );
};
// ResetStyle(FilterItem, { wrappers: ['filter-reset'] })
export default React.forwardRef(ResetStyle(FilterItem, { wrappers: ['filter-reset'] }));
// export default React.forwardRef((FilterItem));
